update e2c 6

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



global procedure foo(integer x, integer y) 

would be exported as "_0foo" or maybe "_1foo" etc. The underscore and digit are added to prevent naming conflicts. The digit refers to the Euphoria file where the identifier is defined. The main file is numbered as 0. The include files are numbered in the order they are encountered by the compiler. You should check the C source to be sure.

For Watcom, the Translator also creates an EXPORT command, added to objfiles.lnk for each exported identifier, so foo would be exported as "foo".

With Watcom, if you specify the -makefile option, you can edit the objfiles.lnk file to rename the exported identifiers, or remove ones that you do not want to export. Then build with the generated makefile.

Having nice exported names is not critical, since the name need only appear once in each Euphoria program that uses the shared dynamically loading library, i.e. in a single define_c_func or define_c_proc statement. The author of a shared dynamically loading library should probably provide his users with a Euphoria include file containing the necessary define_c_func and define_c_proc statements, and he might even provide a set of Euphoria "wrapper" routines to call the routines in the shared dynamically loading library.

When you call open_dll, any top-level Euphoria statements in the shared dynamically loading library will be executed automatically, just like a normal program. This gives the library a chance to initialize its data structures prior to the first call to a library routine. For many libraries no initialization is required.

To pass Euphoria data (atoms and sequences) as arguments, or to receive a Euphoria object as a result, you will need to use the following constants in euphoria\include\dll.e:

-- Euphoria types for shared dynamically loading library arguments  
-- and return values: 
 
global constant 
    E_INTEGER = #06000004, 
    E_ATOM    = #07000004, 
    E_SEQUENCE= #08000004, 
    E_OBJECT  = #09000004 

Use these in define_c_proc and define_c_func just as you currently use C_INT, C_UINT etc. to call C shared dynamically loading libraries.

Currently, file numbers returned by open, and routine id's returned by routine_id, can be passed and returned, but the library and the main program each have their own separate ideas of what these numbers mean. Instead of passing the file number of an open file, you could instead pass the file name and let the shared dynamically loading library open it. Unfortunately there is no simple solution for passing routine id's. This might be fixed in the future.

A Euphoria shared dynamically loading library currently may not execute any multitasking operations. The Translator will give you an error message about this.

Euphoria shared dynamically loading library can also be used by C programs as long as only 31-bit integer values are exchanged. If a 32-bit pointer or integer must be passed, and you have the source to the C program, you could pass the value in two separate 16-bit integer arguments (upper 16 bits and lower 16 bits), and then combine the values in the Euphoria routine into the desired 32-bit atom.

Using Resource Files

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu